<?php

namespace common\models\task;

use common\enums\StatusEnum;
use common\helpers\ArrayHelper;
use Yii;

/**
 * This is the model class for table "{{%web_list}}".
 *
 * @property int $id
 * @property string $title 标题
 * @property string $img 图片
 * @property string $tap 备注
 */
class WebList extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%web_list}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['title', 'img'], 'required'],
            [['status'],'safe'],
            [['title', 'img', 'tap'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'title' => Yii::t('app', '标题'),
            'img' => Yii::t('app', '图片'),
            'tap' => Yii::t('app', '备注'),
        ];
    }

    public static function getList()
    {
        return ArrayHelper::map(self::find()->where(['status'=>StatusEnum::ENABLED])->all(),'id','title');
    }
}
